package com.rran.study.designpattern.behavioral.mediator;

import com.rran.study.designpattern.behavioral.mediator.colleague.HourseOne;
import com.rran.study.designpattern.behavioral.mediator.colleague.HourseTwo;
import com.rran.study.designpattern.behavioral.mediator.mediator.HourseMediator;

/**
 * @author yy
 * @Type MediatorApplication.java
 * @Desc
 * @date 2020/7/23 16:11
 */
public class MediatorTest {

    /**
     * 将房子托管给中介
     * 当一个房子涨价，另一个房子也涨相同的价格
     * @param args
     */
    public static void main(String[] args) {

        HourseOne hourseOne = new HourseOne(1000L);
        HourseTwo hourseTwo = new HourseTwo(2000L);
        System.out.println("hourseOne 的价格为"+hourseOne.getPrice());
        System.out.println("hourseTwo 的价格为"+hourseTwo.getPrice());
        HourseMediator mediator = new HourseMediator();
        mediator.register(hourseOne);
        mediator.register(hourseTwo);
        hourseOne.upHoursePrice(100L);
        System.out.println("hourseOne 涨价了100");
        System.out.println("hourseTwo 的价格为"+hourseTwo.getPrice());
        hourseTwo.upHoursePrice(200L);
        System.out.println("hourseTwo 涨价了200");
        System.out.println("hourseOne 的价格为"+hourseOne.getPrice());
        hourseOne.upHoursePrice(100L);
        System.out.println("hourseOne 涨价了100");
        System.out.println("hourseTwo 的价格为"+hourseTwo.getPrice());

    }
}
